import redis
import logging


class Config(object):

    # 调试模式配置
    DEBUG = True

    # 数据库的配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@localhost:3306/information16"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis的配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # CSRF的配置
    SECRET_KEY = "fcnealiuvfiaeuvf"

    SESSION_TYPE = "redis"
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = 172800

    # 等级设置
    LEVEL = logging.DEBUG


class DevelopConfig(Config):
    pass


class ProductConfig(Config):
    LEVEL = logging.ERROR
    DEBUG = False


class TestingConfig(Config):
    Testing = True


# 配置环境的统一入口
config_dict = {
    "develop": DevelopConfig,
    "product": ProductConfig,
    "testing": TestingConfig
}